<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class HistoryHargaModel extends zulModel{

	function __construct(){
			parent::__construct();
			$this->table_name	= "history_harga";
			$this->primary_key	= "ID_HISTORY_HARGA";
			$this->order_by		= "ID_HISTORY_HARGA DESC";
	}
	function gridHistoryHarga(){
		$this->db->select('ID_HISTORY_HARGA,NAMA_OBAT,HISTORY_HARGA,TGL_HISTORY');
		$this->db->from('history_harga');
		$this->db->join("obat","obat.ID_OBAT=history_harga.ID_OBAT");
		$this->flexigrid->build_query();
		$return['records'] = $this->db->get();
		
		$this->db->select('ID_HISTORY_HARGA,NAMA_OBAT,HISTORY_HARGA,TGL_HISTORY');
		$this->db->from('history_harga');
		$this->db->join("obat","obat.ID_OBAT=history_harga.ID_OBAT");
		$this->flexigrid->build_query(FALSE);
		$return['record_count'] = $this->db->count_all_results();

		return $return;
	}
	function join($pk=FALSE){
		$this->db->select("*")->from($this->table_name);
		$this->db->join("obat","obat.ID_OBAT=".$this->table_name.".ID_OBAT");
		if($pk == TRUE){
			$this->db->where($this->primary_key,$pk);
			$method	= "row_array";
		} else {
			$method	= "result";
		}
		$query	= $this->db->get();
		return $query->$method();
	}
}
?>